package com.hydra.cron.server.builder;

import com.hydra.cron.common.utils.SysUtil;
import com.hydra.cron.server.model.CronServer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Created by lee on 15/12/22.
 */
public class CronServerBuilder {
    private final static Logger logger = LoggerFactory.getLogger(CronServerBuilder.class);
    public static CronServer build(String token, String jobName, boolean isLeader) {
        CronServer cronServer = new CronServer();
        cronServer.setLeader(isLeader);
        cronServer.setToken(token);
        cronServer.setJobName(jobName);
        cronServer.setProcessSuccessCount(0);
        cronServer.setProcessFailureCount(0);
        cronServer.setHostName(SysUtil.getLocalIp());
        cronServer.setLeaderStoped(false);
        cronServer.setStatus(CronServer.ServerStatus.READY);
        return cronServer;
    }

    public static void main(String[] args) {
        logger.info("logback 成功了");
        logger.error("logback 成功了");
    }
}
